<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
    <div style="margin-top: 20px;">
    </div>
    <form class="layui-form" id="admin">
        <input name="id" type="hidden" value="{$data.id}" >
        <div class="layui-form-item">
            <label class="layui-form-label">签订日期</label>
            <div class="layui-input-inline">
                <input type="text" value="{$data.qiandate}" name="qiandate" class="layui-input" id="test1" placeholder="yyyy-MM-dd">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">选择户主</label>
            <div class="layui-input-inline">
                <select name="uid" lay-verify="required" lay-search="">
                    <option value="">直接选择或搜索选择</option>
                    {volist name="huzhu" id="vo"}
                    <option <?php if($data['uid']==$vo['id']) echo "selected";?> value="{$vo.id}">{$vo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div id="number">
            <div class="layui-form-item">
                <label class="layui-form-label">按期拆迁奖励</label>
                <div class="layui-input-inline">
                    <input value="{$data.anqijiang}" name="anqijiang" lay-verify="required" placeholder="按期拆迁奖励" autocomplete="off" class="layui-input" type="number">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">自助租房奖励</label>
                <div class="layui-input-inline">
                    <input value="{$data.zizhujiang}" name="zizhujiang" lay-verify="required" placeholder="自助租房奖励" autocomplete="off" class="layui-input" type="number">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">搬家费</label>
                <div class="layui-input-inline">
                    <input value="{$data.banjiafei}" name="banjiafei" lay-verify="required" placeholder="搬家费" autocomplete="off" class="layui-input" type="number">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">装修补助</label>
                <div class="layui-input-inline">
                    <input value="{$data.zhuangxiubu}" name="zhuangxiubu" lay-verify="required" placeholder="装修补助" autocomplete="off" class="layui-input" type="number">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">生活补助</label>
                <div class="layui-input-inline">
                    <input value="{$data.shenghuobu}" name="shenghuobu" lay-verify="required" placeholder="生活补助" autocomplete="off" class="layui-input" type="number">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">租房补助</label>
                <div class="layui-input-inline">
                    <input value="{$data.zufangbu}" name="zufangbu" lay-verify="required" placeholder="租房补助" autocomplete="off" class="layui-input" type="number">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">冬季取暖补助</label>
                <div class="layui-input-inline">
                    <input value="{$data.qunuanbu}" name="qunuanbu" lay-verify="required" placeholder="冬季取暖补助" autocomplete="off" class="layui-input" type="number">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">其它1</label>
                <div class="layui-input-inline">
                    <input value="{$data.qita1}" name="qita1" lay-verify="required" placeholder="其它1" autocomplete="off" class="layui-input" type="number">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">其它2</label>
                <div class="layui-input-inline">
                    <input value="{$data.qita2}" name="qita2" lay-verify="required" placeholder="其它2" autocomplete="off" class="layui-input" type="number">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">小计</label>
            <div class="layui-input-inline">
                <input value="{$data.sum}" name="sum" id="sum" lay-verify="required" readonly placeholder="自动计算" autocomplete="off" class="layui-input" type="text">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <script>
        $("#number input[type=number]").blur(function(){
            var valueArr= $('input[type=number]');
            var sumValue=0;
            if(valueArr.size()>0||valueArr != null){
                for (var i=0;i<valueArr.size();i++ )
                {
                    if(isNaN(valueArr[i].value)||valueArr[i].value==null||valueArr[i].value==""){
                        sumValue +=0;
                    }
                    else{
                        //alert(valueArr[i].value);
                        sumValue +=parseFloat(valueArr[i].value);
                    }

                }
            }
            if(sumValue>0){
                $('#sum').val(parseInt(sumValue));
            }
            else{
                $('#sum').val(0);
            }
        })
    </script>
    <script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                    $ = layui.jquery,
                    layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>
    <script>
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            //常规用法
            laydate.render({
                elem: '#test1'
            });
        })
    </script>
    <script>
        layui.use(['layer', 'form'], function() {
            var layer = layui.layer,
                    $ = layui.jquery,
                    form = layui.form;
            $(window).on('load', function() {
                form.on('submit(admin)', function(data) {
                    $.ajax({
                        url:"{:url('admin/xieyi/xieyi_gexiang_edit')}",
                        data:$('#admin').serialize(),
                        type:'post',
                        async: false,
                        success:function(res) {
                            if(res.code == 1) {

                                layer.alert('提交成功！',{icon:6}),

                                setTimeout(function(){
                                    parent.location.reload();
                                },1500)
                            }else {
                                layer.msg(res.msg);
                            }
                        }
                    })
                    return false;
                });
            });
        });
    </script>
</div>
</body>
</html>